package de.connecttext.deprecated;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class FileDao {


	
	
	/**
	 * UmSchReiben zu: getTextContentOfFIle!!
	 * @param directory
	 * @return
	 * @throws Exception
	 */
	public List<String> getTextContentOfDirectory(String directory) throws Exception {
		
		List<File> textFiles = FileCrawler.getInstance().getTextFiles(
				new File(directory));
		
		FileReader ready = new FileReader();
		List<String> toReturn = new ArrayList<String>();
		// Für Alle TextFiles, tokenize und zähle die Wörter!
		for (File file : textFiles) {

			toReturn.add(ready.readFile(file));
			
		}

		return toReturn;		
		
	}

	/*public Map<String, Integer> getSortedWordMap() {
		return sortedWordMap;
	}
	
	private static Map<String, Integer> sortByValue(Map<String, Integer> map) {
		List<Entry<String, Integer>> list = new LinkedList<Entry<String, Integer>>(map.entrySet());
		Collections.sort(list, new Comparator<Entry<String,Integer>>() {
			public int compare(Entry<String,Integer> o1, Entry<String,Integer> o2) {
				return o1.getValue().compareTo(o2.getValue());
			}
		});
		Collections.reverse(list);
		Map<String, Integer> result = new LinkedHashMap<String, Integer>();
		for (Iterator<Entry<String,Integer>> it = list.iterator(); it.hasNext();) {
			Entry<String,Integer> entry = it.next();
			result.put(entry.getKey(), entry.getValue());
		}
		return result;
	}*/

}
